package cn.momoky.ccool.repository;

import cn.momoky.ccool.mapper.UserMapper;
import cn.momoky.ccool.pojo.User;
import cn.momoky.ccool.utils.ResultStatus;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Repository;

@Repository
@AllArgsConstructor
public class UserRepository extends ServiceImpl<UserMapper, User> {

    private final UserMapper userMapper;

    public User verificationUser(String name){
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
        userQueryWrapper.lambda()
                .eq(User::getName,name)
                .eq(User::getStatus, ResultStatus.NORMAL_USER.getCode())
                .last("LIMIT 1");
        return userMapper.selectOne(userQueryWrapper);
    }

}
